import { defineEventHandler, readBody } from 'h3';

export default defineEventHandler(async (event) => {
  const body = await readBody(event);
  const {
    copyReason,
    copyScope,
    isTemplate,
    templateName,
    templateDescription,
  } = body;

  // 模拟复制资源的过程
  const copiedResourceId = Math.floor(Math.random() * 1000) + 100; // 生成新的资源ID
  const copyRecordId = Math.floor(Math.random() * 1000) + 1; // 生成复制记录ID

  // 返回复制结果
  return {
    code: 0,
    message: '复制成功',
    data: {
      originalResourceId: 1, // 这里应该是从URL参数获取的原始资源ID
      copiedResourceId,
      copyRecordId,
      copyTime: new Date().toISOString(),
      copyScope: copyScope || 'private',
      isTemplate: isTemplate || false,
      templateName: templateName || null,
      templateDescription: templateDescription || null,
    },
  };
});
